/******************************************************************************
* Copyright (C),     - 2015    ,  LINTER. Co., Ltd
* File name:  UDS_ServiceList.h
* Author: Andy Gao           Version: 1.0              Data:2015-07-27
* DESCRIPTION: 
*
* Others:
*
*
* History:
*       1.
*        Author:
*        Data:
*        Modification:
*       2.
*
*****************************************************************************/
#ifndef  __UDS_SERVICE_H__
#define  __UDS_SERVICE_H__


#ifdef __cplusplus
extern "C" {
#endif

#define  UDS_SUPPORTED_YES     1
#define  UDS_SUPPORTED_NO      0
/*********************************************************************************************/
/*********************************************************************************************/
// SID table
#define SID_DIAGNOSTIC_SESSION_CONTROL			0x10
#define SID_ECU_RESET							      0x11
#define SID_CLEAR_DIAGNOSTIC_INFORMATION		0x14
#define SID_READ_DTC_INFORMATION				0x19
#define SID_READ_DATA_BY_IDENTIFIER				0x22
#define SID_READ_MEMORY_BY_ADDRESS				0x23
#define SID_READ_SCALING_DATA_BY_IDENTIFIER		0x24
#define SID_SECURITY_ACCESS						0x27
#define SID_COMMUNICATION_CONTROL				0x28
#define SID_READ_DATA_BY_PERIODIC_IDENTIFIER	0x2A
#define SID_DYNAMICALLY_DEFINE_DATA_IDENTIFIER	0x2C
#define SID_WRITE_DATA_BY_IDENTIFIER			0x2E
#define SID_INPUT_OUTPUT_CONTROL_BY_IDENTIFIER	0x2F
#define SID_ROUTINE_CONTROL						0x31
#define SID_REQUEST_DOWNLOAD   					0x34
#define SID_TRANSFER_DATA    						0x36
#define SID_REQUEST_TRANSFER_EXIT      				0x37
#define SID_WRITE_MEMORY_BY_ADDRESS				0x3D
#define SID_TESTER_PRESENT						0x3E
#define SID_NEGATIVE_RESPONSE					0x7F
#define SID_CONTROL_DTC_SETTING					0x85


#define SID_DIAGNOSTIC_SESSION_CONTROL_LENGTH	2
#define SID_ECU_RESET_LENGTH						2
#define SID_CLEAR_DIAGNOSTIC_INFORMATION_LENGTH	4
#define SID_READ_DTC_INFORMATION_01_LENGTH				3
#define SID_READ_DTC_INFORMATION_02_LENGTH				3
#define SID_READ_DTC_INFORMATION_04_LENGTH				6
#define SID_READ_DTC_INFORMATION_06_LENGTH				6
#define SID_READ_DTC_INFORMATION_0A_LENGTH				2
#define SID_CONTROL_DTC_SETTING_LENGTH			2
#define SID_COMMUNICATION_CONTROL_LENGTH            3
#define SID_TESTER_PRESENT_LENGTH                            2
#define SID_SECURITY_ACCESS_R_LENGTH                      2
#define SID_SECURITY_ACCESS_S_LENGTH                      6

#define SID_ROUTINE_CONTROL_0203_LENGTH                4


#define SID_REQUEST_DOWNLOAD_LENGTH                11
#define SID_REQUEST_TRANSFER_EXIT_LENGTH                1

#define SID_INPUT_OUTPUT_CONTROL_BY_IDENTIFIER_00_01_LENGTH	 4
#define SID_INPUT_OUTPUT_CONTROL_BY_IDENTIFIER_3901_03_LENGTH	 5
#define SID_INPUT_OUTPUT_CONTROL_BY_IDENTIFIER_3902_03_LENGTH	 5
#define SID_INPUT_OUTPUT_CONTROL_BY_IDENTIFIER_3903_03_LENGTH	 5
#define SID_INPUT_OUTPUT_CONTROL_BY_IDENTIFIER_3904_03_LENGTH	 8
#define SID_INPUT_OUTPUT_CONTROL_BY_IDENTIFIER_3905_03_LENGTH	 5
#define SID_INPUT_OUTPUT_CONTROL_BY_IDENTIFIER_3906_03_LENGTH	 5
#define SID_INPUT_OUTPUT_CONTROL_BY_IDENTIFIER_3907_03_LENGTH	 5
/*********************************************************************************************/
/*********************************************************************************************/
typedef void (*UDS_SERVICE_NRC_FUN)(u8*);

typedef struct  __UDS_Service_NRC_tab_
{
    u8 NrcID;
    UDS_SERVICE_NRC_FUN   NRC_Fun;
}UDS_ServiceNRC_Tab;
/*********************************************************************************************/
/*********************************************************************************************/
typedef void (*UDS_SERVICE_DID_FUN)(u8*,u16 );

typedef struct  __UDS_Service_DID_tab_
{
    u16 DID;
    UDS_SERVICE_DID_FUN   DID_Fun;
}UDS_ServiceDID_Tab;
/*********************************************************************************************/
/*********************************************************************************************/
typedef struct  __UDS_Service_SupportedSession_
{
	u8 bit3_7:5;
	u8 Extended:1;
	u8 Programming:1;
	u8 Default:1;
}UDS_ServiceSSession;
/*********************************************************************************************/
/*********************************************************************************************/
typedef struct  __UDS_Service_SecurityAccess_
{
	u8 bit2_7:6;
	u8 Level2:1;
	u8 Level1:1;
}UDS_ServiceSAccess;
/*********************************************************************************************/
/*********************************************************************************************/
typedef struct  __UDS_Service_Addressing_
{
	u8 bit2_7:6;
	u8 Functional:1;
	u8 Physical:1;
}UDS_ServiceAddressing;
/*********************************************************************************************/
/*********************************************************************************************/
typedef void (*UDS_SERVICE_FUN)(u8*, u16, u8);
typedef struct  __UDS_Service_SID_tab_
{
    u8 SID;
    UDS_ServiceDID_Tab * DID_Tab;
    UDS_ServiceSSession    SSession;
    UDS_ServiceSAccess     SAccess;
    UDS_ServiceAddressing  Addressing;
    UDS_SERVICE_FUN Fun;
}UDS_ServiceSID_Tab;

/*********************************************************************************************/
/*********************************************************************************************/

extern UDS_ServiceSID_Tab  const  UDSFun_ServiceList[];
extern u16 const UDSFun_ServiceListNum;

#ifdef __cplusplus
}
#endif
/*********************************************************************************************/
/*********************************************************************************************/

#endif
